package com.sgb.kjwl.view.ui.adapter.personmanger;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.PersonInfoEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class AddPersonAdapter extends BaseRecycleAdapter<PersonInfoEntity> {
    private TextView tv_add;
    private AddOrDeleteListener addOrDeleteListener;

    public AddPersonAdapter(Context context, List<PersonInfoEntity> datas) {
        super(context, R.layout.item_add_person, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, PersonInfoEntity powerEntity) {
        holder.setBinding(BR.viewModel, powerEntity);
        tv_add = holder.itemView.findViewById(R.id.tv_add);
        tv_add.setOnClickListener(view -> {
            addOrDeleteListener.addOrDelete(powerEntity.getId());
        });
    }

   public interface AddOrDeleteListener {
        void addOrDelete(String userId);
    }

    public void setAddOrDeleteListener(AddOrDeleteListener addOrDeleteListener) {
        this.addOrDeleteListener = addOrDeleteListener;
    }
}
